<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">

	</head>
	<body>
		<h1>axios的简化</h1>
	
		<script src="../js/axios.js"></script>
		<script>
			//http://localhost:8085/getUserById?id=1
		axios.get("http://localhost:8085/getUserById",{
			params:{
				id:3
			}
		}).then(result=>{
			console.log(result.data)
		})
		
		//函数定义
		async function getUser(){
			//代替then()的方式接受返回值结果
			const result=await axios.get("http://localhost:8085/getUserById",{
				params:{id:3}
			})
			console.log(result)
			console.log(result.data)
		}
		
		async function getUser2(){
			//代替then()的方式接受返回值结果
			//此处的result和data都不是上面意义上的，
			const {data:result,status:code}=await axios.get("http://localhost:8085/getUserById",{
				params:{id:3}
			})
			console.log("axios的简化操作")
			console.log(result)
			console.log(code)
		}
		
		// axios.get("url")
		// .then(result=>{
			
		// })
		
		
		
		
		// aysnc function aa(){
		// 	const {data:result1}=await axios.get(url1)
		// 	const {data:result2}=await axios.get(url1,result1)
			
			
		// }
		
		
		
		//函数调用
		getUser()
		getUser2()
		
		</script>
	</body>
</html>
